package Zuoye.zuoye2;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = sc.next();
        //验证用户名：八位。不能以数字开头，只能用数字，字母，下划线，$组成
        String regex = "^[a-zA-Z_$][a-zA-Z0-9_$]{7,}$";
        if (name.matches(regex)){
            System.out.println("用户名输入正确");
        }else {
            System.out.println("用户名输入错误");
        }
        System.out.println("请输入密码：");
        String password = sc.next();
        //验证密码，首位必须是字母且必须大写，密码长度必须大于8位，只能用数字，字母，下划线，$组成
        String regex1 = "^[a-zA-Z][a-zA-Z0-9_$]{7,}$";
        if (password.matches(regex1)){
            System.out.println("密码输入正确");
        }else {
            System.out.println("密码输入错误");
        }
        System.out.println("请输入邮箱号：");
        String email = sc.next();
        String regex2 = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
        if (email.matches(regex2)){
            System.out.println("邮箱输入正确");
        }else {
            System.out.println("邮箱输入错误");
        }
    }

}
